package com.buba.springcloud.service;

import com.buba.springcloud.dao.HfOrderMapper;
import com.buba.springcloud.entities.HfFoods;
import com.buba.springcloud.entities.HfOrders;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class HfOrederServiceImpl implements HfOrederService{
    @Resource
    private HfOrderMapper hfOrderMapper;

    @Override
    public List<HfOrders> getOrders(String orderCode,String userName,String phone,Integer status) {
        List<HfOrders> orders = hfOrderMapper.getHforeders(orderCode,userName,phone,status);
        List<HfFoods> foods = null;
        for (HfOrders order : orders) {
            foods = hfOrderMapper.getOrderFoods(order.getId());
            order.setFoods(foods);
//           if (foods.size()!=0){
//               for (HfFoods food : foods) {
//                   order.getFoods().add(food);
//               }
//           }
        }
        return orders;
    }
}
